


#include "inc_file.h"


int main(void)
{
	u8 i=0;
	u16 t =0;
	static float jianduCha=0;
	sysTemConfig();
	Mt6701Init();
	pwm_init(TIM1,PWM1DUTYMAX);
	mot1ZeroOff();
	//sysTf.Mot1ZeroOff2 =_PI_3- sysTf.Mot1ZeroOff2;
	Time7Init();
	pidFullInit();
	lpFullInit();
	//systick_CountMode();
	CAN_GPIO_Config();
	CAN_Config();
    while (1){
		++i;
		if( (systf.mot1Sta==MotorShunShi || systf.mot1Sta==MotorNiShi)){
			//systf.Mot1SvpwmFunc();
			/*
			pwm1Stop();
			systick_CountMode();
			while(t<9999){
				SvpwmFucn();
				++t;
				IWG_IWG_Reload();
			}
			printfS("%d  %d\r\n",SysTick->VAL,SysTick->LOAD - SysTick->VAL);
			t =0;
			*/
		}
		switch(i){
			case 1:
				ms1Func();
				break;
			case 2:
				if( systf.mot1Sta!=MotorShunShi && systf.mot1Sta!=MotorNiShi)break;
				if(systf.Mot1FocFunc == angleAndSpeedFoc){
					jianduCha =  systf.Mot1AngleSp -systf.Mot1Angle;
					arm_abs_f32(&jianduCha,&jianduCha, 1);
					if(jianduCha <0.5f)msgAddQueue(k_angleFoc, 0);
				 }
				break;
			case 3:break;
			case 4:msgRes();break;
			case 5:break;
			case 6:break;
			case 7:break;
			case 8:break;
			case 9:break;
			default :
					i=0;
					IWG_IWG_Reload();
				break;
			
			
		}					
	
    }
}

